#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a =0 ,b = 0,c = 1,d = 0;
    int n = 0;
    cin >> a;
    for(int i = 1; i <= a;i++){
    	b = 0;
		c = 1;
		n = 0;
	    while(pow(10,n) <= i){
	        b += (int)(i / pow(10,n)) % 10;
	        c *= (int)(i / pow(10,n)) % 10;
	        n += 1;
	    }
	    if(b >= 20){
	    	if(c >= 162){
	    		d += 1;
			}
		}
		
	}
	cout << d;
    return 0;
}
